<%@page import="ContentManagers.Servlets.ServletCustomerLogin"%>
<div id="register_login" class="content_box">
    
    <% //This section is for the simple login lockout mechanism. 
            try{
                
            ServletCustomerLogin.resetIfTimeOut(request); 
            
            if(session.getAttribute("formLockout").toString().equals("off"))
                {  //login form will appear if attemptCount < 5
                    System.out.print(session.getAttribute("formLockout"));
                %>
                <div id="login_div">
                    Already registered? Login here.

                    <form name ="user_login" method="post" onsubmit="" action="ServletCustomerLogin">
                        <input class="inputbox" type="text" value="Username" id="regUsernameField" name="username" autocomplete ="off" onfocus="clearInitial(this, 'Username')" onBlur="checkRegLogin()"/>
                        <input class="inputbox" type="password" value="Password" id="regPasswordField" name="password" autocomplete ="off" onfocus="clearInitial(this, 'Password')" onBlur="checkRegLogin()"/>
                        <input type="submit" id="regSubmitLoginButton" name="SubmitUserLogin" value="Login" disabled/>
                            <% 
                            if(session.getAttribute("errorMessage")!=null)
                            {
                                if(session.getAttribute("errorMessage").equals("invalid"))
                                    out.println("<Br>Invalid username or password.");
                                session.removeAttribute("errorMessage");
                            }
                            %>
                    </form>
                    

                </div>
                
               <% }
            else 
                { //display this div if attemptCount = 5
                
                %>
                    <div id="login_div">
                        Login lockout for 5minutes.
                    </div>
                
               <% } %>
    
    
    <div id="register_div">
        New to foobar? Register here!
        
        <form name ="user_register" method="post" onsubmit="return validateRegistration()" action="ServletRegister">
            <table class ="reg">
                <tr><td colspan="2"><b>Personal Information</td></tr>
                                <tr><td>&nbsp;&nbsp;Last Name:</td>
                    <td><input maxlength="45" class="inputbox" type="text" value="Last Name" name="newUserLastName" autocomplete ="off" onfocus="clearInitial(this, 'Last Name')" onblur="checkLastInput(this)"/>
                    </td></tr><tr><td>&nbsp;&nbsp;First Name: </td>
                    <td><input maxlength="45" class="inputbox" type="text" value="First Name" name="newUserFirstName" autocomplete ="off" onfocus="clearInitial(this, 'First Name')" onblur="checkLastInput(this)"/>
            
                    </td></tr><tr><td>&nbsp;&nbsp;Middle Initial: </td>
                    <td><input class="inputbox" type="text" value="Middle Initial" name="newUserMiddleName" autocomplete ="off" maxlength="1" onfocus="clearInitial(this, 'Middle Initial')" onblur="checkLastInput(this)"/>
                    </td></tr>
            <tr><td colspan="2"><b>Account Information </td></tr>
                    <tr><td>&nbsp;&nbsp;Username: </td>
                            <td><input maxlength="20" class="inputbox" type="text" value="Username" name="newUsername" autocomplete ="off" onfocus="clearInitial(this, 'Username')" onblur="checkLastInput(this)"/>
                            </td></tr><tr><td>&nbsp;&nbsp;Password:</td> 
                            <td><input maxlength="20" class="inputbox" type="password" value="Password" name="newPassword" autocomplete ="off" onfocus="clearInitial(this, 'Password')" onblur="checkLastInput(this)"/>
                            </td></tr><tr><td>&nbsp;&nbsp;Re-enter Password: </td>
                            <td><input maxlength="20" class="inputbox" type="password" value="Password" name="newPassword2" autocomplete ="off" onfocus="clearInitial(this, 'Password')" onblur="checkLastInput(this)"/>
                            </td></tr><tr><td>&nbsp;&nbsp;E-mail:</td> 
                            <td><input maxlength="45" class="inputbox" type="text" value="E-mail Address" name="newEmail" autocomplete ="off" onfocus="clearInitial(this, 'E-mail Address')" onblur="checkLastInput(this)"/>
                            </td></tr>
            
            <tr><td colspan="2"><b>Billing Address </td></tr>
            <tr><td>&nbsp;&nbsp;House No.: </td>
                    <td><input maxlength="4" class="inputbox" type="text" value="House Number" name="billingHouseNumber" autocomplete ="off" onfocus="clearInitial(this, 'House Number')" onblur="checkLastInput(this)"/>
                    </td></tr><tr><td>&nbsp;&nbsp;Street: </td>
                    <td><input maxlength="45" class="inputbox" type="text" value="Street" name="billingStreet" autocomplete ="off" onfocus="clearInitial(this, 'Street')"/>
                    </td></tr><tr><td>&nbsp;Subdivision: </td> 
                    <td><input maxlength="45" class="inputbox" type="text" value="Subdivision" name="billingSubdivision" autocomplete ="off" onfocus="clearInitial(this, 'Subdivision')" onblur="checkLastInput(this)"/>
                    </td></tr><tr><td>&nbsp;&nbsp;City: </td>
                    <td><input maxlength="45" class="inputbox" type="text" value="City" name="billingCity" autocomplete ="off" onfocus="clearInitial(this, 'City')"/>
                    </td></tr><tr><td>&nbsp;&nbsp;Postal Code: </td>
                    <td><input maxlength="10" class="inputbox" type="text" value="Postal Code" name="billingPostalCode" autocomplete ="off" onfocus="clearInitial(this, 'Postal Code')" onblur="checkLastInput(this)"/>
                    </td></tr><tr><td>&nbsp;&nbsp;Country: 
                    <td><input maxlength="45" class="inputbox" type="text" value="Country" name="billingCountry" autocomplete ="off" onfocus="clearInitial(this, 'Country')" onblur="checkLastInput(this)"/>
                    </td></tr>
            
            
            <tr><td colspan="2"><b>Delivery Address&nbsp; &nbsp; </b><smallfont> Same as billing: </smallfont> <input type="checkbox" name="deliveryAdd" value="sameAsBilling" autocomplete ="off" onClick="if(this.checked) {duplicateFields();}"/>
               </td></td>
                <tr><td>&nbsp;&nbsp;House No.: </td>
                    <Td><input maxlength="4" class="inputbox" type="text" value="House Number" name="deliveryHouseNumber" autocomplete ="off" onfocus="clearInitial(this, 'House Number')" onblur="checkLastInput(this)"/>
                </td></tr><tr><td>&nbsp;&nbsp;Street: </td>
                    <td><input maxlength="45" class="inputbox" type="text" value="Street" name="deliveryStreet" autocomplete ="off" onfocus="clearInitial(this, 'Street')"/>
                </td></tr><tr><td>&nbsp;Subdivision: </td>
                    <td><input maxlength="45" class="inputbox" type="text" value="Subdivision" name="deliverySubdivision" autocomplete ="off" onfocus="clearInitial(this, 'Subdivision')" onblur="checkLastInput(this)"/>
                </td></tr><tr><td>&nbsp;&nbsp;City: </td> 
                    <td><input maxlength="45" class="inputbox" type="text" value="City" name="deliveryCity" autocomplete ="off" onfocus="clearInitial(this, 'City')"/>
                </td></tr><tr><td>&nbsp;&nbsp;Postal Code: </td>
                    <td><input maxlength="10" class="inputbox" type="text" value="Postal Code" name="deliveryPostalCode" autocomplete ="off" onfocus="clearInitial(this, 'Postal Code')" onblur="checkLastInput(this)"/>
                </td></tr><tr><td>&nbsp;&nbsp;Country: </td>
                    <td><input maxlength="45" class="inputbox" type="text" value="Country" name="deliveryCountry" autocomplete ="off" onfocus="clearInitial(this, 'Country')" onblur="checkLastInput(this)"/>
                </td></tr>
            
            <tr><td colspan="2"><b>Credit Card Info</td></tr>
            <tr><td>&nbsp;&nbsp;Name on Card:</Td>
                <td><input maxlength="45" class="inputbox" type="text" value="Name on Card" name="creditName" autocomplete ="off" onfocus="clearInitial(this, 'Name on Card')" onblur="checkLastInput(this)"/>
            </td></tr><tr><td>&nbsp;&nbsp;Credit Card No.: </td>
                <td><input maxlength="20" class="inputbox" type="text" value="Credit Card No." name="creditCardNo" autocomplete ="off" onfocus="clearInitial(this, 'Credit Card No.')" onblur="checkLastInput(this)"/>
            </td></tr><tr><td>&nbsp;&nbsp;Credit Card Type:</td>
                <Td><select name="creditCardType">
                    <option value="null">- Card Type -</option>
                    <option value="Visa">Visa</option>
                    <option value="Master Card">Master Card</option>
                    </select>
            </td></tr><tr><td>&nbsp;&nbsp;Expiration Date:</td>
                <td><input maxlength="11" class="inputbox" type="text" value="YYYY-MM-DD" name="creditExpiryDate" autocomplete ="off" onfocus="clearInitial(this, 'YYYY-MM-DD')" onblur="checkLastInput(this)"/>
                        
                </td></tr><tr><td></td><td><input type="submit" name="SubmitUserRegistration" name="submituserRegistration" value="Register"/></td></tr></table>
            
        </form>
             <%if(session.getAttribute("errorMessage")!=null)
             {
                if(session.getAttribute("errorMessage").equals("1"))
                    out.println("<Br>User already exist");
                else if (session.getAttribute("errorMessage").equals("2"))
                    out.println("<Br>A registration error has occured.");
                session.removeAttribute("errorMessage");
             }
            %>
    </div>
    
</div>
               
       <% }
    catch(Exception e)
        {   session.setAttribute("formLockout", "off");
            session.setAttribute("errorMessage", "00");
            response.sendRedirect("index_new_user.jsp");
        }%>